/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.experimentation;

import co.edu.unal.bioingenium.kbmed.knowledge.KnowledgeSourceMetaData;
import co.edu.unal.bioingenium.kbmed.knowledge.dao.KnowledgeSourceDAO;
import co.edu.unal.bioingenium.kbmed.knowledge.dao.KnowledgeSourceDAOFactory;
import co.edu.unal.bioingenium.kbmed.knowledge.snomed.SnomedMetaData;
import co.edu.unal.bioingenium.kbmed.retrieval.text.process.PrepareByWords;
import co.edu.unal.bioingenium.kbmed.text.representation.io.CorpusIO;
import co.edu.unal.bioingenium.kbmed.text.representation.vo.Corpus;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author Ing. Alejandro Riveros Cruz
 */
public class ConceptAllTerms {

    public static void main(String[] args) {
        KnowledgeSourceDAO knowledgeSourceDAO = KnowledgeSourceDAOFactory.getKnowledgeSourceDAO();
        PrepareByWords prepareCollection = new PrepareByWords();
        Corpus corpus;
        Map<String, Set<String>> termsByconceptIds = knowledgeSourceDAO.getTermsByConceptId();
        Map<String, String> corpusData = new HashMap<String, String>(termsByconceptIds.size());
        StringBuilder stringBuilder = new StringBuilder();
        for (String conceptId : termsByconceptIds.keySet()) {
            stringBuilder.setLength(0);
            for (String term : termsByconceptIds.get(conceptId)) {
                stringBuilder.append(term).append(" ");
            }
            corpusData.put(conceptId, stringBuilder.toString());
        }
        corpus = prepareCollection.buildCorpus("conceptAllTerms", corpusData, 0, 0);
        CorpusIO.storeCorpus(corpus, "conceptAllTerms.dat");
    }
}
